package 
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.system.Security;
	
	import game.AppFacade;
	import game.define.ProtocolDefine;
	
	import utiles.StageProxy;
	import utiles.net.NetworkManager;
	import utiles.net.QProtocol;
	
	[SWF(frameRate="24",height="600",width="800",backgroundColor="0xffffff")]
	public class Main extends Sprite
	{
		private var _rootContainer:Sprite;
		
		public function Main()
		{
			Security.allowDomain("*");
			this.mouseEnabled = false;
			
			_rootContainer = new Sprite();
			_rootContainer.mouseEnabled = false;
			addChild(_rootContainer);
			
			addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		}
		
		public function get viewRoot():Sprite
		{
			return _rootContainer;
		}
		
		private function onAddedToStage(event:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			StageProxy.registerStage(stage);
			StageProxy.registerRootContainer(_rootContainer);
			
			var facade:AppFacade = AppFacade.getInstance();
			facade.startup();
			
			getUserInfo();
		}
		
		private function getUserInfo():void
		{
			var protocol:QProtocol = new QProtocol();
			protocol.type = ProtocolDefine.USER_INFO_REQ;
			protocol.body = {};
			NetworkManager.instance.sendMsg(protocol);
		}
	}
}